/**
 * Created by heht on 2017/3/27.
 */
import Vue from 'vue'
import Vuex from 'vuex'
import createLogger from 'vuex/dist/logger'
import * as actions from './actions'
import * as getters from './getters'
Vue.use(Vuex)

const state = {
  // 提示框
  tip: {
    text: '',
    time: 2000,
    callback: null
  },
  // 加载圈圈
  loading: {
    visible: false,
    callback: null
  },
  // 是否重新刷新页面数据
  rePage: true,
  // 股票详情页滚动位置
  scrHeight: 0,
  // 是否登录
  getmobile: 0
}

const mutations = {
  // 提示框
  SET_TIP (state, tip) {
    state.tip = tip
  },
  // 加载圈圈
  SET_LOADING (state, loading) {
    state.loading = loading
  },
  // 是否进入股票详情页时重新加载数据
  SET_REPAGE (state, rePage) {
    state.rePage = rePage
  },
  // 股票详情页滚动位置
  SET_SCRHEIGHT (state, y) {
    state.scrHeight = y
  },
  // 是否登录
  SET_GETMOBILE (state, getmobile) {
    state.getmobile = getmobile
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions,
  getters,
  plugins: [createLogger()]
})
